<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>包裹添加</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/xadmin.js"></script>
    <script type="text/javascript" src="js/cookie.js"></script>
</head>

<body>
<script>
    $(function () {
        $("#add").click(function (){
            var id=$("#L_id").val();
            var sourceNode=$("#L_sourceNode").val();
            var targetNode=$("#L_targetNode").val();
            var status=$("#L_status").val();
            var uid=$("#L_uid").val();
            $.ajax({
                url: "http://localhost:8080/package/save/"+uid,
                type: "post",
                dataType: "JSON",
                contentType : "application/json; charset=utf-8",
                data: JSON.stringify({"id":id,"sourceNode":sourceNode,"targetNode":targetNode, "status":status}),
                success : function(data) {
                    var obj=data;
                    if(obj.code.code === 0){
                        alert("添加成功");
                        x_admin_father_reload();
                        x_admin_close();
                    }else {
                        alert(obj.code.message);
                    }
                },
                error : function() {
                    alert("error");
                }
            });
        });
    });
</script>
<div class="x-body">
    <form class="layui-form-item">
        <div class="layui-form-item">
            <label for="L_id" class="layui-form-label">
                <span class="x-red">*</span>包裹编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_id" name="id" required="" lay-verify="id" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_sourceNode" class="layui-form-label">
                <span class="x-red">*</span>源节点
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_sourceNode" name="sourceNode" required="" lay-verify="sourceNode" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_targetNode" class="layui-form-label">
                <span class="x-red">*</span>目的节点
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_targetNode" name="targetNode" required="targetNode" lay-verify="targetNode" autocomplete="off" class="layui-input">
            </div>
        </div>
        <!--<div class="layui-form-item">-->
            <!--<label for="L_createTime" class="layui-form-label">-->
                <!--<span class="x-red">*</span>创建时间-->
            <!--</label>-->
            <!--<div class="layui-input-inline">-->
                <!--<input type="text" id="L_createTime" name="createTime" required="createTime" lay-verify="createTime" autocomplete="off" class="layui-input">-->
            <!--</div>-->
        <!--</div>-->
        <div class="layui-form-item">
            <label for="L_status" class="layui-form-label">
                <span class="x-red">*</span>状态
            </label>
            <div class="layui-input-inline">
                <input type="text" value="0" readonly="readonly" id="L_status" name="status" required="status" lay-verify="status" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_uid" class="layui-form-label">
                <span class="x-red">*</span>用户编号
            </label>
            <div class="layui-input-inline">
                <input type="text" id="L_uid" name="uid" required="uid" lay-verify="uid" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button type="button"  class="layui-btn" id="add" lay-filter="add" lay-submit="" style="width: 100px;margin-left: 20px">添加</button>
        </div>
    </form>
    <table id="table">

    </table>
</div>
<script>
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form
            ,layer = layui.layer;

        //自定义验证规则
        form.verify({
            id: function(value){
                if(value === '' || value === null){
                    return '编号不能为空';
                }
            }
            ,sourceNode: function(value){
                if(value === '' || value === null){
                    return '源节点不能为空';
                }
            }
            ,targetNode: function(value){
                if(value === '' || value === null){
                    return '目的节点不能为空';
                }
            }
            ,status: function(value){
                if(value === '' || value === null){
                    return '状态不能为空';
                }
            }
            ,uid: function(value){
                if(value === '' || value === null){
                    return '用户编号不能为空';
                }
            }
        });
    });
</script>
</body>
</html>